{% extends 'homepage.html' %}
{% block content %}

<script>
var cur_system = null;
function show_code(system) {
    $('.sage').hide();
    $('.pari').hide();
    $('.magma').hide();
    if (cur_system == null) {
      $('.'+system).show();
      cur_system = system;
    } else {
      $('.'+system).hide();
      cur_system = null;
    }
}
</script>

    <div align ="right">
      Show commands for:  <a onclick="show_code('sage'); return false" href='#'>sage</a>,
        <a onclick="show_code('pari'); return false" href='#'>pari</a>,
        <a onclick="show_code('magma'); return false" href='#'>magma</a>
    </div>
    <div></div>

<p>
  <div class='sage nodisplay code'>sage: K = NumberField({{info.rawpoly}},'a')</div>
  <div class='pari nodisplay code'>pari: K = bnfinit({{info.rawpoly}})</div>
  <div class='magma nodisplay code'>&gt; K&lt;a&gt; := NumberField(PolynomialRing(Rationals())!{{info.coefficients}});</div>
</p>
        {% set KNOWL_ID = "nf.%s"|format(info['label']) %}
        <h2>{{ KNOWL_INC(KNOWL_ID+'.top', title='') }}</h2>

        <p><h2> {{ KNOWL('nf.defining_polynomial', title='Defining polynomial') }}</h2>
        <div class='sage nodisplay code'>sage: K.defining_polynomial()</div>
        <div class='pari nodisplay code'>pari: K.pol</div>
        <div class='magma nodisplay code'>&gt; DefiningPolynomial(K);</div>
        <p>
            {{ info.polynomial }}
        </p>

        <p><h2> {{ KNOWL('nf.invariants', title='Invariants') }}</h2>
        <div class='sage nodisplay code'>sage: K.degree()</div>
        <div class='sage nodisplay code'>sage: K.signature()</div>
        <div class='sage nodisplay code'>sage: K.disc()</div>
        <div class='sage nodisplay code'>sage: K.disc().support()</div>
        <div class='pari nodisplay code'>pari: poldegree(K.pol)</div>
        <div class='pari nodisplay code'>pari: K.sign</div>
        <div class='pari nodisplay code'>pari: K.disc</div>
        <div class='pari nodisplay code'>pari: factor(abs(K.disc))[,1]~</div>
        <div class='magma nodisplay code'>&gt; Degree(K);</div>
        <div class='magma nodisplay code'>&gt; Signature(K);</div>
        <div class='magma nodisplay code'>&gt; Discriminant(K);</div>
        <div class='magma nodisplay code'>&gt; PrimeDivisors(Discriminant(K));</div>
        <p>
          <table>
            <tr><td>Degree:<td>&nbsp;&nbsp;<td>{{info.degree}}</tr>
            <tr><td>Signature:<td>&nbsp;&nbsp;<td>{{info.signature}}</tr>
            <tr><td>Discriminant:<td>&nbsp;&nbsp;<td>{{info.discriminant}}</tr>
            <tr><td>Ramified primes:<td>&nbsp;&nbsp;<td>{{info.ram_primes}}</tr>
          </table>
        </p>

{% if info.degree==1 %}
        <p><h2> {{ KNOWL('nf.integral_basis', title='Integral basis') }} </h2>
{% endif %}
{% if info.degree!=1 %}
        <p><h2> {{ KNOWL('nf.integral_basis', title='Integral basis') }} (with respect to {{ KNOWL('nf.field_generator', title='field generator') }} \(a\))</h2>
{% endif %}
        <div class='sage nodisplay code'>sage: K.integral_basis()</div>
        <div class='pari nodisplay code'>pari: K.zk</div>
        <div class='magma nodisplay code'>&gt; IntegralBasis(K);</div>
        <p>
            {{ info.integral_basis }}
        </p>

        <p><h2> {{ KNOWL('nf.ideal_class_group', title='Class group') }} and  {{ KNOWL('nf.class_number', title='class number') }}</h2>
        <div class='sage nodisplay code'>sage: K.class_group().invariants()</div>
        <div class='pari nodisplay code'>pari: K.clgp</div>
        <div class='magma nodisplay code'>&gt; ClassGroup(K);</div>
	<p>
          {{ info.class_group }}, order {{info.class_number}}
        </p>


        <p><h2> {{ KNOWL('nf.unit_group', title='Unit group') }}</h2>
        <div class='sage nodisplay code'>sage: UK = K.unit_group()</div>
        <div class='sage nodisplay code'>sage: UK.rank()</div>
        <div class='sage nodisplay code'>sage: UK.torsion_generator()</div>
        <div class='sage nodisplay code'>sage: UK.roots_of_unity()</div>
        <div class='sage nodisplay code'>sage: K.regulator()</div>

        <div class='pari nodisplay code'>pari: #K.fu</div>
        <div class='pari nodisplay code'>pari: K.tu[2]</div>
        <div class='pari nodisplay code'>pari: K.fu</div>
        <div class='pari nodisplay code'>pari: K.reg</div>

        <div class='magma nodisplay code'>&gt; UnitRank(K);</div>
        <div class='magma nodisplay code'>&gt; K!f(TorsionSubgroup(UK).1);</div>
        <div class='magma nodisplay code'>&gt; [K!Integers(K)!f(u) : u in Generators(UK)];</div>
        <div class='magma nodisplay code'>&gt; Regulator(K);</div>
        <p>
          <table>
            <tr><td>Rank:<td>&nbsp;&nbsp;<td>${{info.unit_rank}}$</tr>
            <tr><td>Torsion generator:<td>&nbsp;&nbsp;<td>{{info.root_of_unity}}</tr>
{% if info.unit_rank==1 %}
            <tr><td>Fundamental unit:<td>&nbsp;&nbsp;<td>{{info.fund_units|safe}}</tr>
{% endif %}
{% if info.unit_rank>1 %}
            <tr><td>Fundamental units:<td>&nbsp;&nbsp;<td>{{info.fund_units|safe}}</tr>
{% endif %}
            <tr><td>Regulator:<td>&nbsp;&nbsp;<td>{{info.regulator}}</tr>
          </table>
        </p>


        <p><h2> {{ KNOWL('nf.galois_group', title='Galois group') }}</h2>
        <div class='sage nodisplay code'>sage: K.galois_group(type='pari')</div>
        <div class='pari nodisplay code'>pari: polgalois(pol)</div>
        <div class='magma nodisplay code'>&gt; GaloisGroup(K);</div>
        <p>
            {{ info.galois_group | safe }}:
          <table>
            <tr><td>{{ info.phrase }}</tr>
            <tr><td>
            {{ info.cclasses | safe }}</tr>
            <tr><td>
            {{ info.character_table | safe }}</tr>
          </table>

        <p><h2> {{ KNOWL('nf.frobenius_cycle_types', title='Frobenius cycle types') }}</h2>
        <p><center>
           <table class="ntdata" >
	    <thead>
             <tr><th>$p$</th>
            {% for p in info.frob_data %}
            <td>{{ p[0] | safe }} </td>
            {% endfor %}
             </tr>
	    </thead>
	    <tbody>
             <tr><th>Cycle type</th>
            {% for p in info.frob_data %}
            <td>{{ p[1] | safe }} </td>
            {% endfor %}
             </tr>
	     </tbody>
           </table>
	   </center>
        </p>
<p>
   In the table, <i>R</i> denotes a ramified prime.  Cycle lengths 
   which are repeated in a cycle type are indicated by exponents.
        <p>
  <div class='pari nodisplay code'>
   To obtain a list of [\(e_i, f_i\)] for the factorization of the ideal
 \(p\mathcal{O}_K\) <br>
pari: 
<br>
  p = 7;  \\ set a prime
<br>
  idealfactors = idealprimedec(K, p); \\ get the data
<br>
  vector(length(idealfactors), j, [idealfactors[j][3], idealfactors[j][4]])
</div>
  <div class='sage nodisplay code'>
   sage:
<br>
  p = 7   # set a prime
<br>
  idealfactors = K.factor(p)  # get the data
<br>
  [[e, primefactor.residue_class_degree()] for primefactor,e in idealfactors]
  </div>
  <div class='magma nodisplay code'>
<br>
  p := 7;   # set a prime
<br>
  idealfactors := Factorization(p*Integers(K));  # get the data
<br>
  [<Valuation(Norm(primefactor[1]), p), primefactor[2]> : primefactor in idealfactors];
</div>

{% if info.get("tim_number_field", False) %}
	<p><h2> {{ KNOWL('artin', title='Artin representations') }}</h2>
		{# This is now correct #}
        <div>
	<center>
	<table class="ntdata">
	<thead><tr><td></td><td>{{ KNOWL('artin.dimension', title='Dimension') }}</td><td>{{ KNOWL('artin.conductor', title='Conductor') }}</td><td>Defining polynomial of {{ KNOWL('artin.number_field', title='Artin Field') }} </td><td>Galois subgroup</td></tr></thead>
	<tbody>
        {% for artin in info["tim_number_field"].artin_representations()%}
          <tr> <td><a href = "{{artin.url_for()}}">{{loop.index}}</a></td><td>${{artin.dimension()}}$</td><td>${{artin.conductor()}}$</td>
	  {% if artin.number_field_galois_group().url_for() %}
	     <td><a href="{{artin.number_field_galois_group().url_for()}}">${{artin.number_field_galois_group().polredabs()}}$</a></td>
	  {% else %}
	      <td>${{artin.number_field_galois_group().polredabs()}}$</td>
	  {% endif %}
	  <td>${{artin.number_field_galois_group().G_name()}}$</td></tr>
        {% endfor %}
	</tbody>
	</table>
	</center>
	</div>
	{% endif %}
{# POD: Please leave the part above for the public release. This part on Artin representations is ready.
	However it is not possible at the moment to search or browse Artin representations, so they should not appear in the sidebar.
	Also not yet available are Artin L-functions.
#}

        {% set KNOWL_ID = "nf.%s"|format(info['label']) %}
        <h2>{{ KNOWL_INC(KNOWL_ID+'.bottom', title='') }}</h2>

{% endblock %}
